<?php

declare(strict_types=1);

namespace App\Fastapp\Model;

use Hyperf\Database\Model\Relations\HasOne;
use Mine\MineModel;

/**
 * @property int $id 主键
 * @property int $source 来源1tg
 * @property string $group_id 群id
 * @property string $role 权限
 * @property int $bot_id
 * @property-read null|FastappRobot $robot
 * @property-read null|FastappRobotGroup $group
 */
class FastappRobotGroupAuth extends MineModel
{
    public bool $timestamps = false;
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'fastapp_robot_group_auth';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = ['id', 'source', 'group_id', 'role', 'bot_id'];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'source' => 'integer', 'bot_id' => 'integer'];

    public function robot(): HasOne
    {
        return $this->hasOne(FastappRobot::class, 'id', 'bot_id');
    }

    public function group(): HasOne
    {
        return $this->hasOne(FastappRobotGroup::class, 'group_id', 'group_id');
    }
}
